<template>
	<view class="beijingse">
		<u-sticky bgColor="#bbbbbb">
			<view class="mainpadding" style="position: relative; z-index: 2;">
				<view class="ffffff flexbetween ssbox">
					<view class="flexleft">
						<u-icon name="search" color="#999" size="20"></u-icon>
						<input type="text" placeholder="请输入搜索内容" class="hei_text main_size bold" v-model="keywords" confirm-type="search" @confirm="init">
					</view>
					<view class="rightss" @click="init">搜索</view>
				</view>
			</view>
		</u-sticky>
		<view class="" style="background-color: #bbbbbb;" v-if="list.total">
			<view class="mainpadding ffffff" :class="index==0?'':'margin_top'" v-for="(item,index) in list.data" :key="item.id"
				@click="jumpdetail('/pages_shouye/mendianxq?id=',item.id)">
				<view class="flexleft">
					<image class="listleftimg margin_right2 hearradius" :src="item.logo_text" mode=""></image>
					<view class="flexcolumnbet" style="height: 120rpx;">
						<view class="titletext hei_text bold">{{item.name}}</view>
						<view class="flexbetween">
							<view class="flexleft">
								<u-icon name="man-add" color="#ff9341" size="16"></u-icon>
								<view class="xiaohuang margin_right margin_left1 strongtext">粉丝{{item.gz_num}}个</view>
								<u-icon name="eye" color="#999" size="16"></u-icon>
								<view class="xiaohui margin_right margin_left1 strongtext">浏览{{item.view_num}}次</view>
							</view>
							<!-- <view class="xiaohong margin_right margin_left1 strongtext">折扣{{Number(item.score_rate)/100}}</view> -->
						</view>
						<view class="flexbetween">
							<view class="flexleft">
								<u-icon name="map" color="#ff9341" size="16"></u-icon>
								<view class="xiaohui margin_left1 main_size xiankuan" style="width: 300rpx;">
									{{item.address_detail}}</view>
							</view>
							<view class="xiaohuang main_size">{{returnKmUnit(Number(item.distance))}}</view>
						</view>
					</view>
				</view>
				
				<view class="flexleft flex_wrap">
					<view class="flexcenter margin_top" style="width: 33.33%;">
						<image class="listleftimg2 radius" :src="item.mtz_image_text" mode="">
						</image>
					</view>
					<view class="flexcenter margin_top" style="width: 33.33%;" v-if="hjzindex==0 || hjzindex==1" v-for="(hjz,hjzindex) in item.hjz_image_text">
						<image class="listleftimg2 radius" :src="hjz" mode="">
						</image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				type:1,//1查看全部不做筛选，2大家爱去，3最新商家，4筛选分类
				category_id:"",
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				cityid:"",
				areaid:"",
				lat:"",
				lng:"",
				keywords:"",
			}
		},
		onLoad(options) {
			if(options.keywords){
				this.keywords = options.keywords
			}
			if(options.msg){
				let data = JSON.parse(decodeURIComponent(options.msg))
				this.type = data.type
				this.category_id = data.category_id
				uni.setNavigationBarTitle({
					title:data.navname
				})
			}
			let storagecity = uni.getStorageSync("storagecity") || null
			if(storagecity){
				this.lat = storagecity.latitude
				this.lng = storagecity.longitude
				this.cityid = storagecity.cityid
			}
			let storagearea = uni.getStorageSync("storagearea") || null
			if(storagearea){
				this.areaid = storagearea.areaid
			}
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this
				httpRequest.request('/api/shopcl/shopIndex', 'GET', {
					page: page || 1,
					limit: _this.limit,
					lat:this.lat,
					lng:this.lng,
					city_id:this.cityid,
					area_id:this.areaid,
					zx_shop:this.type==3?1:0,
					gz_sort:this.type==2?1:0,
					category_id:this.category_id,
					keyword:this.keywords
					
				}).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			jumpdetail(url, id) {
				uni.navigateTo({
					url: url + id
				})
			}
		}
	}
</script>

<style>

</style>
